//package com.yunxin.admin.system.api.system.task;
//
//import cn.hutool.core.collection.ListUtil;
//import cn.hutool.core.date.DateField;
//import cn.hutool.core.date.DateTime;
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.util.ObjectUtil;
//import com.fasterxml.jackson.core.type.TypeReference;
//import com.yunxin.common.utils.JacksonUtils;
//import com.yunxin.core.application.admin.team.DistributeDo;
//import com.yunxin.core.application.admin.team.Team;
//import com.yunxin.core.application.admin.team.TeamTaskDistribute;
//import com.yunxin.core.domain.model.order.OrderUserApplyAllocationRepository;
//import com.yunxin.core.infra.persistence.mapper.order.OrderTeamTaskDetailMapper;
//import com.yunxin.core.utils.infra.support.lock.DistributedLock;
//import com.yunxin.core.utils.infra.support.lock.DistributedLockFactory;
//import com.yunxin.core.utils.infra.support.lock.TaskLockKey;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.net.InetAddress;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Component
//@Slf4j
//@RequiredArgsConstructor
//public class TestTask {
//
//
//    private final OrderUserApplyAllocationRepository orderUserApplyAllocationRepository;
//
//    private final OrderTeamTaskDetailMapper teamTaskDetailMapper;
//
//    private final DistributedLockFactory distributedLockFactory;
//
//    @Scheduled(cron = "0/10 * * * * *")
//    @Transactional(rollbackFor = Exception.class)
//    public void teamTask() {
//        try {
//            TaskLockKey taskLockKey = TaskLockKey.test_LOCK_KEY;
//            DistributedLock lock = distributedLockFactory.provideDistributedLock(taskLockKey.getPrefix());
//            boolean tryLock = lock.tryLock(taskLockKey.getWaitTime(), taskLockKey.getReleaseTime(), taskLockKey.getTimeUnit());
//            String hostAddress = InetAddress.getLocalHost().getHostAddress();
//            if (tryLock){
//                try {
//                    System.out.println("teamTask定时任务开始了 = " + DateUtil.date());
//                    Thread.sleep(9000);
//                }finally {
//                    if (lock.isHeldByCurrentThread()) {
//                        System.out.println("teamTask定时任务释放锁 = " + DateUtil.date());
//                        lock.unlock();
//                    }
//                }
//            }else {
//                log.info("ip:{},执行TeamTask任务失败,获取锁失败......", hostAddress);
//            }
//        }catch (Exception e) {
//            log.error("执行TeamTask任务异常", e);
//        }
//    }
//}
//
//
//
//
